1. Field of the Invention
The present invention is related to the field of coding a digital video signal in bits, and more specifically to coding at variable bit rate and quantization step size in order to achieve compression and high image quality.
2. Description of the Related Art
Encoders that code digital video in bits achieve compression by choosing optimally a parameter called the quantization step size, also known simply as quantization step. The quantization step size is chosen to address the trade-off between a minimum required image quality and a maximum bandwidth for processing and/or transmission of data.
More specifically, using a larger, coarser quantization step size requires fewer bits to store a scene, but decreases image quality. Conversely, using a smaller, finer quantization step size requires more bits to encode the scene, but produces higher image quality. That is because, although the number of pixels is always the same, with a finer quantization the pixel xe2x80x9cvaluesxe2x80x9d are encoded more accurately. Additionally, for a given quantization step size, the pixel values in simpler scenes are more correlated, and can be described with fewer bits than those in more complex scenes.
There are two main sets of encoding methods in the prior art. The first set of encoding methods, a.k.a. variable bit rate (VBR) mode, is now described with reference to FIGS. 1 and 2. Referring to FIG. 1, the quantization step size is plotted throughout many successive groups of pictures (GOP). (Each xe2x80x9cgroup of picturesxe2x80x9d is usually a group of 12-30 successive frames. The step size can generally change at each frame or image block, in which case FIG. 1 would illustrate the average step size per GOP.)
As can be seen, the quantization step size is maintained nearly uniform, which results in uniform image quality. However, the bit rate (seen in FIG. 2) varies according to scene complexity, hence the name variable bit rate (VBR) mode. When the scene is simpler, the bit rate decreases, and when the scene is complex, the bit rate increases.
The VBR mode is useful in asynchronous transmission mode (ATM). There, the next quantization step size is usually computed by tracking and examining slowly moving average statistics about the complexity of the scene in the frames. As such, the quantization step size can not react quickly to flashes or sudden scene changes, in order to prevent the buffer in the encoder from bit overflow. The tracked statistics typically include the produced bit rate, the target average bit rate, the quantization parameters that are used in previous frames, and other related parameters. More advanced methods use histograms of instantaneous bit rate of typical VBR video, and of other statistics.
The VBR mode is most useful for storing compressed video in CD-ROM or DVD. There are many approaches. The most complex ones encode an entire video frame sequence multiple times, each time with different quantization step sizes. Then, after examining the entire recorded sequences, a single set is selected or created, that has optimized the trade-off between the desired image quality and the desired number of bits. These methods are called multiple pass VBR control methods, and are quite effective in maintaining nearly constant quantization throughout the video sequence. However, these methods are not applicable to real-time encoding, since they result in long delays from the high computational complexity, and require extra memory using these delays.
The second set of prior art encoding methods is now described with reference to FIGS. 3 and 4. These methods are called constant bit rate (CBR) mode, and are intended for transmission through channels with fixed bandwidth. As such, they are most useful for real-time encoding. As can be seen in FIG. 3, the bit rate can be maintained nearly constant for many groups of pictures. However, the quantization step size has to keep changing rapidly, and can end up evolving as shown in FIG. 4. Unfortunately, the rapid quantization changes result in annoying fluctuations of the video image quality, which is a major drawback of the CBR mode.
A difficulty in CBR mode encoding is that a decision has to be made on the quantization step size of an upcoming frame without knowing in advance how complex is the scene. An average value is chosen to begin with, and then various algorithms are used to project a useful quantization step size. In fact, the value of the step size is often modified at each image block of a frame in order to further guarantee that the number of bits produced is close to the desired target. These algorithms typically use statistics for the instantaneous complexity of the scene, and are used to project and adapt the step size for the next scene.
The present invention overcomes these problems and limitations of the prior art.
Generally, the present invention provides a video encoder for encoding a series of groups of frames with an adjustable quantization step, and a method for adjusting the quantization step. The method tracks a complexity parameter of the encoded scenes, and computes a first quantization value in dependence upon the generated complexity parameter. The method further computes a minimum and a maximum step size in dependence upon a number of the bits that have already been generated, and with a preset target number of bits. The quantization step for the next group of pictures is set in accordance with the first quantization value, but subject to the range defined by the minimum and maximum step sizes.
The method further adjusts the minimum and the maximum step sizes to achieve fine tuned performance. The foregoing and other features and advantages of the invention will become more readily apparent from the following detailed description of a preferred embodiment which proceeds with reference to the drawings.